var list = [{
    id: 0,
    url: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fsafe-img.xhscdn.com%2Fbw1%2Fcc161dee-9b86-43bd-aeb5-7400f8f02b68%3FimageView2%2F2%2Fw%2F1080%2Fformat%2Fjpg&refer=http%3A%2F%2Fsafe-img.xhscdn.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1690424742&t=7d0f5e0801fda6bc3228767ba7e25413'
},
{
    id: 1,
    url: 'https://img0.baidu.com/it/u=2398512931,2964497832&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=667'
},
{
    id: 2,
    url: 'https://p3.toutiaoimg.com/origin/pgc-image/251f350ebf6d43e3a02c48c2471f9de1?from=pc'
}];

let box = document.querySelector('.container');
function fn(ele, data) {
    let str = '';
    data.forEach(function(item){
        str += `<img style="width:100px" src="${item.url}">`;
    })
    console.log(str);
    ele.innerHTML = str;
}
fn(box,list);

let img = document.querySelectorAll('img');
let bd = document.body;

img.forEach(function (item) {
    item.onclick = function () {
        bd.background = item.src;
    }
})

